From: Jasper St. Pierre Date: Sat, 16 Feb 2013 04:10:42 +0000 (-0500) Subject: search: Simplify and correct behavior for substring searches X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~4831 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b292bba092829cf76f79521a8958cc0b14d4c886;p=gnome-shell.git search: Simplify and correct behavior for substring searches Early on, search was based on a list of terms, which was like a set of tags, in that terms were OR'd, and that order didn't matter. As such, modifying any one of the terms wouldn't produce new results. Nowadays, providers take the order into account, so a substring should only be the case if new terms are added to the end. https://bugzilla.gnome.org/show_bug.cgi?id=693935 --- diff --git a/js/ui/search.js b/js/ui/search.js index dced01c04..c4eb10c24 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -64,15 +64,12 @@ const SearchSystem = new Lang.Class({ if (!terms) return; - let isSubSearch = terms.length == this._previousTerms.length; - if (isSubSearch) { - for (let i = 0; i < terms.length; i++) { - if (terms[i].indexOf(this._previousTerms[i]) != 0) { - isSubSearch = false; - break; - } - } - } + let searchString = terms.join(' '); + let previousSearchString = this._previousTerms.join(' '); + + let isSubSearch = false; + if (this._previousTerms.length > 0) + isSubSearch = searchString.indexOf(previousSearchString) == 0; let previousResultsArr = this._previousResults;